package com.Annotation;

import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

public class TestClass {
    @BindAddress("http://www.google.com.cn")
    String mAddress;

    @BindPort("8888")
    private String mPort;

    private int mNum;

    @BindGet("mike")
    public void getHttp(String param) {
        String url = "http://www.baidu.com/?username" + param;
        System.out.print("get----------------->" + url);
    }

    public static void main(String[] args) throws IllegalAccessException, InstantiationException, ClassNotFoundException, InvocationTargetException {
        Class c = Class.forName("com.Annotation.TestClass");
        TestClass tc = (TestClass) c.newInstance();
        Method[] methods = c.getDeclaredMethods();
        for (Method method : methods) {
            if (method.isAnnotationPresent(BindGet.class)) {
                BindGet bindGet = method.getAnnotation(BindGet.class);
                String para = bindGet.value();
                method.invoke(tc, para);
            }
        }
    }
}
